// pages/nav/nav_andon_log/nav_andon_log.js*
const behavior = getApp().require("behaviors/requests.js")
Page({
  behaviors: [behavior],
  /**
   * 页面的初始数据
   */
  data: {
    factories: [],
    factoryPicker: false,
    factory: ""
  },
  showFactoryPicker() {
    this.setData({
      factoryPicker: true
    })
  },

  getFactories() {
    const that = this;
    const url = "https://logisticsengineering.gree.com/andon_system/get_factory_list";
    this.get(url).then((res) => {
      that.setData({
        factories: res.data
      })
      console.log(res)
    }).catch((err) => {
      console.log(err)
    })
  },

  onConfirmFactory(ev){
    const {value} = ev.detail
    this.setData({
      factory:value,
      factoryPicker:false
    })
  },

  cancel_factoryPicker(){
    this.setData({
      factoryPicker:false
    })
  },
  
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.getFactories();  
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },
  changePage() {
    if(this.data.factory=="")
    {
      wx.showToast({
        title: '分厂不能为空',
      })
      return
    }
    wx.navigateTo({
      url: "/pages/nav/west_log/west_log?factory="+this.data.factory
    })
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})